﻿using RAP.Framework.Libary.DataSource.Context;
using RAP.Framework.Libary.Utils;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

namespace RAP.Framework.Libary.DataSource.Model
{
  /// <summary>
  /// 数据查询结果对象
  /// </summary>
  public class QueryResult : IQueryResult
  {
    /// <summary>
    /// 
    /// </summary>
    public static QueryResult Success { get; } = new QueryResult();

    /// <summary>
    /// 
    /// </summary>
    public static QueryResult UnknowError { get; } = new QueryResult { Error = new ServiceError { ErrorCode = -1, ErrorMessage = "未知错误！" } };

    /// <summary>
    /// 检测结果是否包含错误
    /// </summary>
    /// <returns></returns>
    public bool HasError
    {
      get
      {
        return this.Error != null;
      }
    }

    /// <summary>
    /// 执行数据查询时发生的错误信息
    /// </summary>
    public ServiceError Error { get; set; }

    /// <summary>
    /// 数据对象
    /// </summary>
    public dynamic Data { get; set; } = new DynamicHashtable();

    /// <summary>
    /// 
    /// </summary>
    public IDataServiceContext DataServiceContext { get; set; }
  }
}
